package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


@Mapper
public interface DishMapper {
    //分页查询菜品:
    @Select("select count(*) from dish where category_id=#{id}")
    Integer countByCategory(Integer id);

    //添加菜品,与 DishFlavorMapper联动添加口味
    @AutoFill(value = OperationType.INSERT)
    void addDish(Dish dish);

    //分页查询菜品
    Page<DishVO> getAllPage(DishPageQueryDTO dishPageQueryDTO);

    //依据id查询菜品对象
    Dish getById(Long id);

    //删除菜品对象
    void deleteDish(List<Long> ids);

    //更新菜品状态
    @AutoFill(value = OperationType.UPDATE)
    void updateDishStatus(Dish dish);

    //依据分类id查询菜品
    List<Dish> getDishByCategoryId(Long categoryId);

    //依据套餐的id查询套餐内菜品
    List<Dish> getBySetmealId(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void updateDishInfo(Dish dish);

    /**
     * 根据条件统计菜品数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
